public class deploymentContentController {

    public deploymentContentController(ApexPages.StandardController controller) {
        file   = new ContentVersion();
        curRef = ApexPages.currentPage().getParameters().get('curRef');
    }
    
    public ContentVersion file { get; set; }
    public string curRef { get; set; }

    public PageReference go() {
         PageReference pr = new PageReference('/apex/tcloser?curRef='+curRef);
        if(curRef != Null){
            file.deployment__c = curRef;
            ContentWorkspace cw =  [SELECT Id, Name FROM ContentWorkspace WHERE name='Projects' limit 1];                     
            file.FirstPublishLocationId = cw.id;          
        }
       
       try{
        insert file;
       pr.setRedirect(true); 
        }catch (Exception e) {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Unable to Upload file :'+e));
            pr = null;
        } 
        //file = null;
        return pr;
    }
    
    //Test methods
    static testMethod  void deploymentContentControllerTest1() {
      //start test
     //test.starttest();
       //create controller object instance to test against
        project__c proj=[select id from project__c limit 1];
       deployment__c dep = new deployment__c( project__c=proj.id);
        ApexPages.StandardController con = new ApexPages.StandardController(new ContentVersion());               
        deploymentContentController Ctlr = new deploymentContentController(con);
        // point the test instance to a page 
        //PageReference pageRef1 = new PageReference('/apex/applicationwiz1');
        //Test.setCurrentPage(pageRef1);
        // methods to test and vars to set
        blob b = blob.valueof('testmethod');
        Ctlr.file.title='TESTMETHOD';
        Ctlr.file.description='TESTMETHOD';
        Ctlr.file.PathOnClient='test.pdf';
        Ctlr.file.VersionData = b;
        Ctlr.go();
        Ctlr.curRef=dep.id;
        Ctlr.go();
       // end the test
     //test.stoptest();  
   } 

}